package org.xtext.runtime.formula;

import java.util.Map;
import java.util.Set;

import org.xtext.runtime.term.Variable;
import org.xtext.runtime.util.Bindings;
import org.xtext.runtime.util.ILogicVisitor;



public class Goal implements IFormula {
	private Predicate formula;
	
	public Goal(Predicate formula) {
		this.formula = formula;
	}

	public Predicate formula() {
		return formula;
	}
	
	@Override
	public Goal copy() {
		return new Goal(formula.copy());
	}

	@Override
	public Set<Variable> variables() {
		return formula.variables();
	}

	@Override
	public Goal apply(Bindings bindings) {
		formula.apply(bindings);
		return this;
	}

	@Override
	public Goal copy(Map<String, Variable> vars) {
		return new Goal(formula.copy(vars));
	}
	
	public String toString() {
		return "!" + formula;
	}

	public String signature() {
		return "!" + formula.signature();
	}

	@Override
	public boolean hasFreeVariables() {
		return formula.hasFreeVariables();
	}

	@Override
	public Object accept(ILogicVisitor visitor) {
		return visitor.visit(this);
	}
}
